
#include "stdafx.h"
#include "LoggerThreadSafe.h"



namespace woe
{
	LoggerThreadSafe::LoggerThreadSafe()
	{
		m_theMtx.initialize();
	}

	LoggerThreadSafe::~LoggerThreadSafe()
	{
		m_theMtx.destroy();
	}


	void LoggerThreadSafe::log(short lvl, short label, const string& strMsg)
	{
		TimeStamp ts;

		//
		//	should meet the current log level
		//
		if (lvl>=current_logger_level_)
		{
			m_theMtx.lock();
			for (TargetEntryList::iterator it= target_entrys_.begin();
				it!=target_entrys_.end();
				it++)
			{
				TargetEntry& entry = *it;
				if (entry.meetRequirement(lvl,label))
				{
					entry.target_->doLog(strMsg, LogLevelUtil::getLogLevelName(lvl), ts);
				}
			}
			m_theMtx.unlock();
		}
	}
}